package utils

import (
	"encoding/json"
	"strings"
)

// Must decode json string else do nothing
func MustDecodeJSONString(data string, bean interface{}) {

	dec := json.NewDecoder(strings.NewReader(data))
	dec.UseNumber() //for long number modification

	dec.Decode(bean)
}

//Must encode json object to string else return empty string
func MustEncodeJSONString(bean interface{}) string {

	v, err := json.Marshal(bean)
	if err == nil {
		return string(v)
	}
	return ""
}
